<template>
	<view class="main-container">
		<view class="banner" style="padding-top: 25rpx">
			<view class="banner_text">
				<text style="margin-left: 25%">科技申报</text>
			</view>
			<view class="banner_text">
				<text style="margin-left: 25%">创新平台</text>
			</view>
		</view>

		<!--导航栏-->
		<orderTabBar :tabList="tabList" @clickTabBar="clickTabBar" class="tab-bar" :show-line="true" />
		<!--订单列表-->
		<view class="policy_list" scroll-y="true" enable-flex>
			<view style="margin: 0 35rpx">
				<view class="list">
					<view class="list_item" v-for="(item, index) in list" :key="index" @click="goDetail(item)">
						<view style="text-align: left">
							{{ item.name }}
						</view>
						<view style="text-align: left; margin-top: 20rpx">
							<view v-if="item.report == 0" style="height: 40rpx; width: 103rpx; border: 1px solid #eee; font-size: 25rpx; border-radius: 10rpx; color: white; padding: 5rpx">
								未申请
							</view>
							<view v-else style="height: 36rpx; width: 120rpx; border: 1px solid #eee; font-size: 25rpx; border-radius: 10rpx; color: white; padding: 5rpx">
								已申请 {{ item.report }}
							</view>
						</view>
					</view>
				</view>
				<!-- <uni-grid :column="2" class="box" style="margin: 15rpx 0rpx" :showBorder="false">
					<uni-grid-item v-for="(item, index) in list" :key="index" v-show="item.name" style="width: 160px; height: 100px">
						<view @click="goDetail(item)" :class="index % 2 == 0 ? 'view_item_right' : 'view_item_left'">
							<view style="text-align: left">
								{{ item.name }}
							</view>
							<view style="text-align: left; margin-top: 20rpx">
								<view v-if="item.report == 0" style="height: 40rpx; width: 103rpx; border: 1px solid #eee; font-size: 25rpx; border-radius: 10rpx; color: white; padding: 5rpx">
									未申请
								</view>
								<view v-else style="height: 36rpx; width: 120rpx; border: 1px solid #eee; font-size: 25rpx; border-radius: 10rpx; color: white; padding: 5rpx">
									已申请 {{ item.report }}
								</view>
							</view>
						</view>
					</uni-grid-item>
				</uni-grid> -->
			</view>
		</view>
	</view>
</template>

<script>
import orderTabBar from '@/wxcomponents/tab_bar.vue';
import uniGrid from '@/components/uni-grid/components/uni-grid/uni-grid.vue';
import uniGridItem from '@/components/uni-grid/components/uni-grid-item/uni-grid-item.vue';
import uniTag from '@/components/uni-tag/components/uni-tag/uni-tag.vue';
import { listStpzdsys } from '@/api/innovate/stpzdsys'; //重点实验室
import { listStpkjyq } from '@/api/innovate/stpkjyq'; //科技园区
import { listStpfhq } from '@/api/innovate/stpfhq'; //孵化器
import { listStpxctd } from '@/api/innovate/stpxctd'; //星创天地
import { listStpgcjsyjzx } from '@/api/innovate/stpgcjsyjzx'; //工程技术研究中心
import { listStpzckj } from '@/api/innovate/stpzckj'; //众创空间
import { listStpcxtd } from '@/api/innovate/stpcxtd'; //创新团队
import { listKJJHXM } from '@/api/source/project/KJJHXM'; //科技项目
import { listKCJJ } from '@/api/source/project/KCJJ'; //科创基金
import { listTECH_PERSON } from '@/api/source/kjrc/TECH_PERSON'; //科技人才
import { listEXPERT_BASIC1 } from '@/api/source/kjrc/EXPERT_BASIC'; //科技人才
import { listQNXXTJB } from '@/api/source/kjrc/QNXXTJB'; ////科技青年新星
import { listKJJJR } from '@/api/source/kjrc/KJJJR'; //科技经纪人
import { listXSCDW } from '@/api/source/kjrc/XSCDW'; //新双创队伍
import { listQypy } from '@/api/innovate/stqypy'; //企业培育
import { listXxyfjg } from '@/api/innovate/stpxxyfjg'; //新型研发机构
export default {
	components: {
		orderTabBar,
		uniGrid,
		uniGridItem,
		uniTag
	},
	data() {
		return {
			showPage: false,
			query: {
				pageNum: '0',
				pageSize: '10',
				memberId: ''
			},
			// 订单列表tab项
			tabList: [
				{
					status: '1',
					title: '平台申报'
				},
				{
					status: 2,
					title: '项目申报'
				},
				{
					status: 3,
					title: '人才申报'
				}
			],
			// 当前选择tab项
			currentIndex: 0,
			// 当前查询状态
			currentStatus: '1',
			// 订单列表高度
			orderHeight: 0,
			// 是否还有更多数据
			noMoreData: {},
			list: [],
			yuanquList: [
				{
					name: '重点实验室',
					id: '0',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/report_shiyanshi_icon_new.png',
					report: '0',
					type: '0'
				},
				{
					name: '科技园区',
					id: '1',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/report_park_icon_new.png',
					report: '0',
					type: '1'
				},
				{
					name: '科技企业孵化器',
					id: '2',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/report_fuhua_icon_new.png',
					report: '0',
					type: '2'
				},
				{
					name: '星创天地',
					id: '3',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/xingchuang_report_search_new.png',
					report: '0',
					type: '3'
				},
				{
					name: '工程技术研究中心',
					id: '4',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/report_jishu_icon_new.png',
					report: '0',
					type: '4'
				},
				{
					name: '众创空间',
					id: '5',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/report_zhongchuang_icon_new.png',
					report: '0',
					type: '5'
				},
				{
					name: '高新技术企业培育',
					id: '6',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/report_team_icon_new.png',
					report: '0',
					type: '6'
				},
				{
					name: '新型研发机构',
					id: '7',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/report_team_icon_new.png',
					report: '0',
					type: '13'
				}
			],
			projectList: [
				{
					name: '科技项目',
					id: '0',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/project_report_search_new.png',
					report: '0',
					type: '7'
				},
				{
					name: '科创基金',
					id: '1',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/money_report_search_new.png',
					report: '0',
					type: '8'
				}
			],
			rencaiList: [
				{
					name: '行业专家',
					id: '0',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/member_report_search_new.png',
					report: '0',
					type: '9'
				},
				{
					name: '宝鸡市青年科技新星',
					id: '1',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/newyounger_report_search_new.png',
					report: '0',
					type: '10'
				},
				{
					name: '科技经纪人',
					id: '3',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/manager_report_search_new.png',
					report: '0',
					type: '11'
				},
				{
					name: '新双创队伍',
					id: '2',
					imageUrl: 'http://113.142.144.25:9301/statics/appimg/team_report_search_new.png',
					report: '0',
					type: '12'
				},
				{
					name: '创新团队',
					id: '4',
					imageurl: 'http://113.142.144.25:9301/statics/appimg/manager_report_search_new.png',
					report: '0',
					type: '14'
				}
			]
		};
	},
	onLoad() {
		this.getUser();
		this.getCount();
	},
	watch: {
		currentStatus: {
			handler(newVal, oldVal) {
				if (newVal == 1) {
					this.list = this.yuanquList;
				} else if (newVal == 2) {
					this.list = this.projectList;
				} else {
					this.list = this.rencaiList;
				}
			},
			immediate: true
		}
	},
	methods: {
		goDetail(item) {
			if (item.report) {
				uni.navigateTo({
					url: '/subpages/pages/report/report_list?type=' + item.type
				});
			} else {
				uni.showToast({
					icon: 'none',
					title: '暂无申报记录！'
				});
			}
		},
		getUser() {
			const value = uni.getStorageSync('userInfo');
			this.query.memberId = value.login_user.member.id;
		},
		// tab切换
		clickTabBar(index, status) {
			this.currentIndex = index;
			this.currentStatus = status;
			console.log(this.yuanquList);
			this.getCount();
		},
		getCount() {
			listStpzdsys(this.query).then((res) => {
				this.yuanquList[0].report = res.total;
			});
			listStpkjyq(this.query).then((res) => {
				this.yuanquList[1].report = res.total;
			});
			listStpfhq(this.query).then((res) => {
				this.yuanquList[2].report = res.total;
			});
			listStpxctd(this.query).then((res) => {
				this.yuanquList[3].report = res.total;
			});
			listStpgcjsyjzx(this.query).then((res) => {
				this.yuanquList[4].report = res.total;
			});
			listStpzckj(this.query).then((res) => {
				this.yuanquList[5].report = res.total;
			});
			listQypy(this.query).then((res) => {
				this.yuanquList[6].report = res.total;
			});
			listXxyfjg(this.query).then((res) => {
				this.yuanquList[7].report = res.total;
			});
			listKJJHXM(this.query).then((res) => {
				this.projectList[0].report = res.total;
			});
			listKCJJ(this.query).then((res) => {
				this.projectList[1].report = res.total;
			});
			listEXPERT_BASIC1(this.query).then((res) => {
				this.rencaiList[0].report = res.total;
			});
			listQNXXTJB(this.query).then((res) => {
				this.rencaiList[1].report = res.total;
			});
			listKJJJR(this.query).then((res) => {
				this.rencaiList[2].report = res.total;
			});
			listXSCDW(this.query).then((res) => {
				this.rencaiList[3].report = res.total;
			});
			listStpcxtd(this.query).then((res) => {
				this.rencaiList[4].report = res.total;
			});
		}
	},
	computed: {}
};
</script>

<style lang="scss" scoped>
.head {
	width: 100%;
	height: 200rpx;
	background-color: #016fb8;
}

.banner {
	width: 95vw;
	height: 280rpx;
	margin-top: 20rpx;
	border-radius: 15rpx;
	background: url('http://113.142.144.25:9301/statics/appimg/banner_shenbao.png');
}

.search {
	background-color: #fff;
	width: 90%;
	margin: 35rpx auto;
	height: 60rpx;
	border-radius: 30rpx;
}

.main-container {
	width: 100vw;
	height: fit-content;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: center;
	background-color: #e6e6e6;
}

.main-container .tab-bar {
	width: 100%;
	margin-top: 20rpx;
}

.main-container .policy_list {
	width: 100%;
	height: fit-content;
	margin-top: 20rpx;
	padding-top: 25rpx;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	background-color: #fff;
}
.list {
	// margin: 50px auto;
	// width: 200px;
	// height: 200px;
	display: grid;
	justify-content: space-between;
	// 划分列 功能函数关键字 repeat （auto-fill，45px）
	// 根据子元素的盒子的份额自动计算可以平铺几次
	grid-template-columns: repeat(auto-fill, 48%);
	// grid-gap 是 row-gap 和 column-gap 的简写形式。
	grid-gap: 0 1px;

	.list_item {
		margin-bottom: 20rpx;
		height: 120rpx;
		font-size: 28rpx;
		color: #fff;
		padding: 20rpx;
		border-radius: 15rpx;
		margin-left: 30rpx;
		text-align: center;
		background-color: coral;
		background: url('http://113.142.144.25:9301/statics/appimg/shenbao_sys.png');
		&:nth-child(even){
			background: url('http://113.142.144.25:9301/statics/appimg/shenbao_cxtd.png');
		}
	}
}
.view_item_left {
	height: 120rpx;
	font-size: 28rpx;
	color: #fff;
	padding: 20rpx;
	border-radius: 15rpx;
	margin-left: 30rpx;
	text-align: center;
	background-color: coral;
	background: url('http://113.142.144.25:9301/statics/appimg/shenbao_sys.png');
	float: left;
}
.view_item_right {
	height: 120rpx;
	font-size: 28rpx;
	color: #fff;
	padding: 20rpx;
	border-radius: 15rpx;
	margin-right: 30rpx;
	text-align: center;
	background-color: cadetblue;
	background: url('http://113.142.144.25:9301/statics/appimg/shenbao_cxtd.png');
	float: right;
}

.banner_text {
	width: 100%;
	text-align: center;
	font-size: 50rpx;
	color: #fff;
	margin-top: 25rpx;
	margin-right: 20%;
	padding-right: 30%;
}
</style>
